import java.io.*;
import javax.microedition.io.*;

public final class x
{

    public SocketConnection a;
    public bz b;
    public s c;
    public DataInputStream d;
    public DataOutputStream e;
    public boolean f;
    public boolean g;
    public boolean h;
    public long i;

    public x(boolean flag)
    {
        f = flag;
        i = System.currentTimeMillis();
    }

    public final void a(byte abyte0[])
    {
        if(!f)
        {
            b.a = new ae(abyte0);
            c.a = new ae(abyte0);
        }
    }

    public final boolean a(String s1)
    {
        try
        {
            String s2 = ce.f(s1);
            a = (SocketConnection)Connector.open(s2);
            a.setSocketOption((byte)0, 0);
            a.setSocketOption((byte)1, 0);
            a.setSocketOption((byte)2, 0);
            if(s1 == s2)
                ce.b(s1, a.getAddress());
            b = new bz(null, a.openInputStream());
            c = new s(a.openOutputStream());
            d = new DataInputStream(b);
            e = new DataOutputStream(c);
        }
        catch(RuntimeException runtimeexception)
        {
            if(!h)
            {
                a();
                throw runtimeexception;
            }
        }
        catch(IOException ioexception)
        {
            if(!h)
            {
                a();
                throw new RuntimeException();
            }
        }
        if(h)
        {
            a();
            return false;
        } else
        {
            return true;
        }
    }

    public final synchronized void a()
    {
        if(!h)
        {
            h = true;
            if(a != null)
            {
                try
                {
                    a.close();
                }
                catch(IOException _ex) { }
                a = null;
            }
            if(e != null)
            {
                try
                {
                    e.close();
                }
                catch(IOException _ex) { }
                e = null;
            }
            if(d != null)
            {
                try
                {
                    if(!ce.a(12))
                        d.close();
                }
                catch(IOException _ex) { }
                d = null;
            }
        }
    }
}